using UnityEngine;
using System.Collections;

public class GUI_Normalizer : MonoBehaviour {
	
    public float x, y;
    public float w = 1;
    public float h = 1;

	void Start () 
    {
        this.guiTexture.pixelInset = new Rect(Screen.width / x + 0.2f, Screen.height / y, (Screen.width - Screen.height) / 3 * w, (Screen.width - Screen.height) / 3 * h);

        if (Screen.width / 16 == Screen.height / 10) //1280x800
        {
            this.guiTexture.pixelInset = new Rect(Screen.width / x + 0.2f, Screen.height / y, (Screen.width - Screen.height) / 3 * w, (Screen.width - Screen.height) / 3 * h);
        }

        if (Screen.width / 16 == Screen.height / 9) //854x480, 960x540
        {
            this.guiTexture.pixelInset = new Rect(Screen.width / x + 0.2f, Screen.height / y, (Screen.width - Screen.height) / 3 * w, (Screen.width - Screen.height) / 3 * h);
        }

        if (Screen.width == 1024 && Screen.height == 600)
        {
            this.guiTexture.pixelInset = new Rect(Screen.width / x, Screen.height / y, (Screen.width - Screen.height) / 3 * w, (Screen.width - Screen.height) / 3 * h);
        } 
        
        if (Screen.width == 1280 && Screen.height == 637)
        {
            this.guiTexture.pixelInset = new Rect(Screen.width / x, Screen.height / y, (Screen.width - Screen.height) / 4 * w, (Screen.width - Screen.height) / 4 * h);
        }
        
        if (Screen.width / 5 == Screen.height / 3) //800x480
        {
            this.guiTexture.pixelInset = new Rect(Screen.width / x, Screen.height / y, (Screen.width - Screen.height) / 3 * w, (Screen.width - Screen.height) / 3 * h);
        }

        if (Screen.width / 4 == Screen.height / 3) //480x320
        {
            this.guiTexture.pixelInset = new Rect(Screen.width / x, Screen.height / y, (Screen.width - Screen.height) / 2.5f * w, (Screen.width - Screen.height) / 2.5f * h);
        }

        if (Screen.width / 3 == Screen.height / 2) //480x320
        {
            this.guiTexture.pixelInset = new Rect(Screen.width / x, Screen.height / y, (Screen.width - Screen.height) / 2.2f * w, (Screen.width - Screen.height) / 2.2f * h);
        }

        
	}
	
	void Update () 
    {
	
	}
}
